#include "Version.h"

#include <string.h>
#include <fan-llvm/core/Core.h>
#include "Type.h"
#include "UnsupportedErr.h"


Type* Version_classType = NULL;
VTable* Version_classVTable = NULL;


/**********************************************
 *
 * Methods and fields
 *
 **********************************************/


/* Bool equals(Obj? obj) */
Bool Version_equals(Obj self, NullableObj obj)
{
  exceptionThrow(UnsupportedErr_newWithFormattedMsg("sys::Version.equals not implemented yet"));
}


/* Int compare(Obj obj) */
Int Version_compare(Obj self, Obj obj)
{
  exceptionThrow(UnsupportedErr_newWithFormattedMsg("sys::Version.compare not implemented yet"));
}


/* Int hash() */
Int Version_hash(Obj self)
{
  exceptionThrow(UnsupportedErr_newWithFormattedMsg("sys::Version.hash not implemented yet"));
}


/* Str toStr() */
Str* Version_toStr(Obj self)
{
  exceptionThrow(UnsupportedErr_newWithFormattedMsg("sys::Version.toStr not implemented yet"));
}


/* Version defVal */
Version* Version_defVal(void)
{
  exceptionThrow(UnsupportedErr_newWithFormattedMsg("sys::Version.defVal not implemented yet"));
}


/* Version? fromStr(Str version, Bool checked) */
Version* Version_fromStr_1(Str* version)
{
  exceptionThrow(UnsupportedErr_newWithFormattedMsg("sys::Version.fromStr not implemented yet"));
}


/* Version? fromStr(Str version, Bool checked) */
Version* Version_fromStr(Str* version, Bool checked)
{
  exceptionThrow(UnsupportedErr_newWithFormattedMsg("sys::Version.fromStr not implemented yet"));
}


/* Version make(Int[] segments) */
Version* Version_make(List* segments)
{
  exceptionThrow(UnsupportedErr_newWithFormattedMsg("sys::Version.make not implemented yet"));
}


/* Int[] segments() */
List* Version_segments(Version* self)
{
  exceptionThrow(UnsupportedErr_newWithFormattedMsg("sys::Version.segments not implemented yet"));
}


/* Int major() */
Int Version_major(Version* self)
{
  exceptionThrow(UnsupportedErr_newWithFormattedMsg("sys::Version.major not implemented yet"));
}


/* Int? minor() */
NullableInt Version_minor(Version* self)
{
  exceptionThrow(UnsupportedErr_newWithFormattedMsg("sys::Version.minor not implemented yet"));
}


/* Int? build() */
NullableInt Version_build(Version* self)
{
  exceptionThrow(UnsupportedErr_newWithFormattedMsg("sys::Version.build not implemented yet"));
}


/* Int? patch() */
NullableInt Version_patch(Version* self)
{
  exceptionThrow(UnsupportedErr_newWithFormattedMsg("sys::Version.patch not implemented yet"));
}


/**********************************************
 *
 * Type-system functions
 *
 **********************************************/


Type* Version_initType(void)
{
  if (Version_classType == NULL)
  {
    Type* baseType = Obj_initType();
    VTable* vtable = Version_initVTable();
    Type* type = Type_new("Version", baseType, vtable, sizeof(Version), sizeof(VersionVTable));
    Type_registerMethodImplementation(type, "build", Version_build, 0);
    Type_registerMethodImplementation(type, "compare", Version_compare, 1);
    Type_registerMethodImplementation(type, "equals", Version_equals, 1);
    Type_registerMethodImplementation(type, "fromStr", Version_fromStr_1, 1);
    Type_registerMethodImplementation(type, "fromStr", Version_fromStr, 2);
    Type_registerMethodImplementation(type, "hash", Version_hash, 0);
    Type_registerMethodImplementation(type, "major", Version_major, 0);
    Type_registerMethodImplementation(type, "make", Version_make, 1);
    Type_registerMethodImplementation(type, "minor", Version_minor, 0);
    Type_registerMethodImplementation(type, "patch", Version_patch, 0);
    Type_registerMethodImplementation(type, "segments", Version_segments, 0);
    Type_registerMethodImplementation(type, "toStr", Version_toStr, 0);
    Type_registerFieldImplementation(type, "defVal", Version_defVal, NULL);
    Version_classType = type;
    Version_initStatic();
  }
  return Version_classType;
}


VTable* Version_initVTable(void)
{
  if (Version_classVTable == NULL)
  {
    VTable* vtable = memoryAlloc(sizeof(VersionVTable));
    memcpy(vtable, Obj_initVTable(), sizeof(FanObjVTable));
    ((FanObjVTable*)vtable)->compare = Version_compare;
    ((FanObjVTable*)vtable)->equals = Version_equals;
    ((FanObjVTable*)vtable)->hash = Version_hash;
    ((FanObjVTable*)vtable)->toStr = Version_toStr;
    Version_classVTable = vtable;
  }
  return Version_classVTable;
}


void Version_initStatic(void)
{
}
